package com.xqgl.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xqgl.bean.Activity;
import com.xqgl.service.ActivityDaoImp;
/**
 * Servlet implementation class addActivityServlet
 */
@WebServlet("/addActivityServlet")
public class addActivityServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public addActivityServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;Charset=utf-8");
		String villagename = request.getParameter("villagename");
		String actitle = request.getParameter("actitle");
		String venue = request.getParameter("venue");
		String accontent = request.getParameter("accontent");
		String organizer = request.getParameter("organizer");
		String acstime = request.getParameter("acstime");
		String acdeadline = request.getParameter("acdeadline");
		String acctime = request.getParameter("acctime");
		String acstate = request.getParameter("acstate");
		
		Activity activity = new Activity();
		activity.setVillagename(villagename);
		activity.setActitle(actitle);
		activity.setVenue(venue);
		activity.setAccontent(accontent);
		activity.setOrganizer(organizer);
		activity.setAcstime(acstime);
		activity.setAcdeadline(acdeadline);
		activity.setAcctime(acctime);
		activity.setAcstate(acstate);
		
		ActivityDaoImp imp = new ActivityDaoImp();
		try {
			imp.add(activity);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("activitylist.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
